package com;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @author yijy
 * @description
 * @create 2020/11/23 上午10:36
 **/
public class ReadFileTest {

    public static void main(String[] args) {
        File file = new File("20201119.txt");
        FileInputStream fis = null;
        StringBuffer sb = new StringBuffer();
        try {
            fis = new FileInputStream(file);
            int length = 0;
            byte[] bytes = new byte[fis.available()];
            while ( (length = fis.read(bytes)) != -1){
                sb.append(new String(bytes,0,length));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(null !=fis){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        System.out.println(sb.toString());
    }

}
